package com.syj.web.controller;

import com.syj.core.variable.SessionUtil;
import com.syj.web.model.User;
import com.syj.web.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author rankai
 *         createTime 2017-02-2017/2/8 14:31
 */
@Controller
@RequestMapping
public class IndexController {

    @Autowired
    private ProductService productService;

    @GetMapping("/")
    public String indexUser(ModelMap map) {
        map.put("productMenu", productService.selectAll());
        return "/user_index";
    }

    @GetMapping("/index/admin")
    public String indexAdmin(ModelMap map) {
        User user = SessionUtil.getUser();
        if (user == null) {
            return "/user_index";
        } else if (user.getStatus() == 1) {
            return "";
        }
        return "";
    }
}
